import request from '@/services/api'

export async function getSightInfoDetail (id: string) {
  const ret = await request.get(`/sight/getSightInfoById?id=${id}`)
  return ret?.data?.sightInfo??{}
}

export async function getComment (id: string) {
  const ret = await request.get(`/comment/getComment?sightId=${id}`)
  return ret?.data?.commentList??[]
}

export async function addComment (content: string, sightId: string, parentId: string) {
  const ret = await request.post('/comment/addComment', {
    content, sightId, parentId
  })
  return ret?.data?.commentId
}

export async function selectLike (id: string) {
  try {
    await request.post(`/comment/like?commentId=${id}`)
  } catch (e) {
    console.log(e)
  }
}

export async function selectDidLike (id: string) {
  try {
    await request.post(`/comment/cancelLike?commentId=${id}`)
  } catch (e) {
    console.log(e)
  }
}

export async function selectSight (sightId: string) {
  try {
    await request.post(`/sight/like?sightId=${sightId}`)
  } catch (e) {
    console.log(e)
  }
}


export async function selectDidSight (sightId: string) {
  try {
    await request.post(`/sight/cancelLike?sightId=${sightId}`)
  } catch (e) {

  }
}

export async function selectCollect (sightId: string) {
  try {
    await request.post(`/sight/collect?sightId=${sightId}`)
  } catch (e) {
    console.log(e)
  }
}

export async function selectDidCollect (sightId: string) {
  try {
    await request.post(`/sight/cancelCollect?sightId=${sightId}`)
  } catch (e) {
    console.log(e)
  }
}
